﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using park.Common;

namespace park.Equipment
{
    public partial class MeteredList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string method = Request.Params["method"];
                if (!string.IsNullOrEmpty(method))
                {
                    switch (method)
                    {
                        case "listMetered":
                            {
                                PrintResult();
                                break;
                            }
                        case "DeleteMetered":
                            {
                                DeleteMetered();
                                break;
                            }
                    }
                    
                }
            }
        }
        private void DeleteMetered()
        {
            string id =Request.Params["id"];

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();
            bool flag = sl.DeleteMetered(id);
            //bool flag = true;

            Response.Write("{" + string.Format("\"isSuccess\":\"{0}\"", flag.ToString().ToLower()) + "}");
            Response.End();
        }
        private void PrintResult()
        {

            int cityId = Utils.IsInt(Request.Params["cityId"]) ? int.Parse(Request.Params["cityId"]):0;
            int areaId = Utils.IsInt(Request.Params["areaId"]) ? int.Parse(Request.Params["areaId"]) : 0;
            int streetId = Utils.IsInt(Request.Params["streetId"]) ? int.Parse(Request.Params["streetId"]) : 0;

            string name = Request.Params["name"];
            int page = int.Parse(Request.Params["page"]);
            int size = int.Parse(Request.Params["size"]);

            cn.linkit.epark.ServiceList sl = new cn.linkit.epark.ServiceList();
            int total = 0;
            string result = sl.ListMetered(cityId,areaId,streetId,name,size,page,ref total);

            //string result = ""
            //    + "[{"
            //    + "\"ID\":1,"
            //    + "\"MeteredNo\":\"TSM4516592\","
            //    + "\"MeteredName\":\"咪表0001\","
            //    + "\"Longitude\":\"15.26\","
            //    + "\"Latitude\":\"66.53\","
            //    + "\"Street\":\"街道口\","
            //    + "\"PricingStrategy\":\"D3\","
            //    + "\"InstalTime\":\"2012-12-05 18:00\","
            //    + "\"Status\":\"正常\","
            //    + "\"Connection\":\"18627870000\""
            //    + "},"
            //    + "{"
            //    + "\"ID\":2,"
            //    + "\"MeteredNo\":\"TSM4516592\","
            //    + "\"MeteredName\":\"咪表0001\","
            //    + "\"Longitude\":\"15.26\","
            //    + "\"Latitude\":\"66.53\","
            //    + "\"Street\":\"街道口\","
            //    + "\"PricingStrategy\":\"D3\","
            //    + "\"InstalTime\":\"2012-12-05 18:00\","
            //    + "\"Status\":\"正常\","
            //    + "\"Connection\":\"18627870000\""
            //    + "}]";

            string json = string.Empty;

            json = "{\"ListMeterd\":" + result + ",\"RowsCount\":" + total + "}";

            Response.Write(json);
            Response.End();
        
        }
    }
}

































